﻿<Window x:Class="MContracts.Dialogs.FilterActsDialog"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        WindowStartupLocation="CenterScreen"
        mc:Ignorable="d" 
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
        xmlns:Converters="clr-namespace:MContracts.Classes.Converters" 
        Loaded="Window_Loaded" Title="Фильтрация по договорам">
    
    <Window.Resources>
        <Converters:ContractConditionConverter x:Key="ContractConditionConverter" />
        <Converters:ContractStateToImageConverter x:Key="ContractStateToImageConverter" />
        <Converters:ContractConditionToImageConverter x:Key="ContractConditionToImageConverter" />
        <Converters:DateTimeToShortDateConverter x:Key="DateTimeToShortDateConverter"/>
        <Converters:ContractGeneralOrSubToImageConverter x:Key="ContractGeneralOrSubToImageConverter"/>
        <Converters:ContractGeneralOrSubToTextConverter x:Key="ContractGeneralOrSubToTextConverter"/>
    </Window.Resources>
    
    <Grid>
        
        <DockPanel LastChildFill="True">

            <StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal" VerticalAlignment="Bottom" Margin="5" HorizontalAlignment="Right" Height="Auto">
                <Button Content="ОК" IsDefault="True" Click="Button_Click_1" Margin="3" Width="100"/>
                <Button Content="Отмена" Click="Button_Click" Margin="3" Width="100"/>
            </StackPanel>
            
            <StackPanel DockPanel.Dock="Top" Orientation="Horizontal" Margin="5">
                <Label Content="Введите значение атрибута "/>
                <TextBox Width="100" TextChanged="TextBox_TextChanged"/>
            </StackPanel>

            <ScrollViewer>
            
                <DataGrid AutoGenerateColumns="False" CanUserAddRows="False" ItemsSource="{Binding Contracts, Mode=OneTime}" x:Name="ContractsDataGrid" HorizontalScrollBarVisibility="Disabled" SelectionMode="Single" SelectionUnit="FullRow">

                    <DataGrid.Columns>

                        <DataGridTemplateColumn Width="Auto">
                            <DataGridTemplateColumn.HeaderTemplate>
                                <DataTemplate>
                                    <CheckBox VerticalAlignment="Center" x:Name="CommonCheckBox" IsThreeState="True" HorizontalAlignment="Center" ToolTip="Выделить / сбросить все элементы" Checked="CheckBox_Checked_1" Unchecked="CheckBox_Unchecked_1"/>
                                </DataTemplate>
                            </DataGridTemplateColumn.HeaderTemplate>
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <CheckBox VerticalAlignment="Center" HorizontalAlignment="Center" ToolTip="Добавить к фильтру" Loaded="CheckBox_Loaded" Checked="CheckBox_Checked" Unchecked="CheckBox_Unchecked"/>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                        </DataGridTemplateColumn>
                    
                        <DataGridTemplateColumn Width="Auto">
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <StackPanel Orientation="Horizontal">
                                        <Image Margin="3" Width="16" Height="16" ToolTip="{Binding Converter={StaticResource ContractGeneralOrSubToTextConverter}}" Source="{Binding  Converter={StaticResource ContractGeneralOrSubToImageConverter}}"/>
                                        <Image Margin="3" Width="16" Height="16" ToolTip="{Binding Contractstate}" Source="{Binding Path=Contractstate, Converter={StaticResource ContractStateToImageConverter}}"/>
                                        <Image Margin="3" Width="16" Height="16" ToolTip="{Binding Path=Condition, Converter={StaticResource ContractConditionConverter}}" Source="{Binding Path=Condition, Converter={StaticResource ContractConditionToImageConverter}}"/>
                                    </StackPanel>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                        </DataGridTemplateColumn>
                        
                        <DataGridTextColumn Header="№" Binding="{Binding Internalnum}" Width="Auto" Foreground="Black"/>
                        
                        <DataGridTemplateColumn Header="Тема договора" Width="4*">
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock TextWrapping="WrapWithOverflow" Text="{Binding Subject}"></TextBlock>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                        </DataGridTemplateColumn>
                        
                        <DataGridTextColumn Header="Дата утверждения" Binding="{Binding Approvedat, Converter={StaticResource DateTimeToShortDateConverter}}" Width="Auto" Foreground="Black"/>
                        
                        <DataGridTemplateColumn Header="Заказчик (Исполнитель)" Width="2*" SortMemberPath="Contractor">
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock TextWrapping="WrapWithOverflow" Text="{Binding Contractor}"></TextBlock>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                        </DataGridTemplateColumn>

                    </DataGrid.Columns>

                </DataGrid>

            </ScrollViewer>

        </DockPanel>

    </Grid>
</Window>
